package com.project.myproject.database;

import com.cmcc.hy.phoenix.audit.log.entity.AuditLogInfo;
import com.cmcc.hy.phoenix.audit.log.service.IOperationLog;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Optional;

/**
 * @author Honorable(mabingqian)
 * @description
 * @date 2020/7/23 19:25
 * @update （更新、优化，注明点）
 */
@Service
public class LogService implements IOperationLog {

    @Resource
    private SerchJPA serchJPA;

    @Override
    public void insert(AuditLogInfo auditLogInfo) {
        serchJPA.save(auditLogInfo);
    }

    @Override
    public AuditLogInfo queryById(Long id) {
        Optional<AuditLogInfo> byId = serchJPA.findById(id);
        if (byId.isPresent()) {
            return byId.get();
        }
        return null;
    }

    @Override
    public void update(AuditLogInfo auditLogInfo) {
        serchJPA.save(auditLogInfo);
    }
}
